package com.swak.frame.ratelimit;

import org.springframework.stereotype.Service;

import com.swak.frame.dto.request.SwakRequest;
import com.swak.frame.dto.response.Responses;
import com.swak.frame.dto.response.RpcResponse;
import com.swak.frame.ratelimit.annotation.RateLimit;

@Service
public class RateLimitDemoServiceImpl implements RateLimitDemoService {

	@RateLimit(qps = 1)
	@Override
	public RpcResponse<String> rateLimitDemo(SwakRequest request) {
		return Responses.buildResponse("ok");
	}

	
	
	/**
	 * 限流增加兜底
	 */
	@RateLimit(qps = 1, fallbackMethod = "fallback")
	@Override
	public RpcResponse<String> rateLimitDemoFallBack(SwakRequest request) {
		return Responses.buildResponse("ok");
	}
	
	
	protected RpcResponse<String> fallback(SwakRequest request) {
		return Responses.buildResponse("fallback");
	}
}
